#ifndef t_prop_h
#define t_prop_h
/*
 * Sylvain BERTRAND <digital.ragnarok@gmail.com>
 * code protected by GNU GPL v3
 */
G_BEGIN_DECLS
enum wm_prop_atom {
	T_PROP_CARDINAL,
	T_PROP_WINDOW,
	T_PROP_PIXMAP,
	T_PROP_ATOM,
	T_PROP_STRING,
	T_PROP_COMPOUND_TEXT,
	T_PROP_UTF8_STRING,
	T_PROP_MANAGER,
	T_PROP_WM_COLORMAP_WINDOWS,
	T_PROP_WM_PROTOCOLS,
	T_PROP_WM_STATE,
	T_PROP_WM_DELETE_WINDOW,
	T_PROP_WM_TAKE_FOCUS,
	T_PROP_WM_NAME,
	T_PROP_WM_ICON_NAME,
	T_PROP_WM_CLASS,
	T_PROP_WM_TRANSIENT_FOR,
	T_PROP_MOTIF_WM_HINTS,
	T_PROP_MOTIF_WM_INFO,
	T_PROP_NET_WM_ORIENTATION_HORZ,
	T_PROP_NET_WM_ORIENTATION_VERT,
	T_PROP_NET_WM_TOPLEFT,
	T_PROP_NET_WM_TOPRIGHT,
	T_PROP_NET_WM_BOTTOMRIGHT,
	T_PROP_NET_WM_BOTTOMLEFT,
	T_PROP_PRIVATE_PADDING1,
	T_PROP_PRIVATE_PADDING2,
	T_PROP_PRIVATE_PADDING3,
	T_PROP_PRIVATE_PADDING4,
	T_PROP_PRIVATE_PADDING5,
	T_PROP_PRIVATE_PADDING6,
	T_PROP_PRIVATE_PADDING7,
	T_PROP_PRIVATE_PADDING8,
	T_PROP_PRIVATE_PADDING9,
	T_PROP_PRIVATE_PADDING10,
	T_PROP_PRIVATE_PADDING11,
	T_PROP_PRIVATE_PADDING12,
	T_PROP_NET_SUPPORTED,
	T_PROP_NET_WM_FULL_PLACEMENT,
	T_PROP_NET_WM_SYNC_REQUEST,
	T_PROP_NET_WM_SYNC_REQUEST_COUNTER,
	T_PROP_LBOXWM_PID,
	T_PROP_LBOXWM_CONFIG_FILE,
	T_PROP_LBOXWM_VERSION,
	T_PROP_LBOXWM_APP_TITLE,
	T_PROP_LBOXWM_APP_NAME,
	T_PROP_LBOXWM_APP_CLASS,
	T_PROP_LBOXWM_APP_TYPE,
	T_PROP_NUM_ATOMS
};
enum wm_prop_text_type {
	T_PROP_TEXT_STRING = 1,
	T_PROP_TEXT_STRING_XPCS = 2,
	T_PROP_TEXT_STRING_NO_CC = 3,
	T_PROP_TEXT_COMPOUND_TEXT = 4,
	T_PROP_TEXT_UTF8_STRING = 5,
};
Atom t_prop_atom(enum wm_prop_atom a);
gboolean t_prop_get32(Window win, Atom prop, Atom type, guint32 *ret);
gboolean t_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret, guint *nret);
gboolean t_prop_get_text(Window win, Atom prop, enum wm_prop_text_type type, gchar **ret);
gboolean t_prop_get_array_text(Window win, Atom prop, enum wm_prop_text_type type, gchar ***ret);
void t_prop_set32(Window win, Atom prop, Atom type, gulong val);
void t_prop_set_array32(Window win, Atom prop, Atom type, gulong *val, guint num);
void t_prop_set_text(Window win, Atom prop, const gchar *str);
void t_prop_erase(Window win, Atom prop);
void t_prop_message(gint screen, Window about, Atom messagetype, glong data0, glong data1, glong data2, glong data3,
	glong data4, glong mask);
void t_prop_message_to(Window to, Window about, Atom messagetype, glong data0, glong data1, glong data2, glong data3,
	glong data4, glong mask);
#define T_PROP_ATOM(prop) t_prop_atom(T_PROP_##prop)
#define T_PROP_GET32(win, prop, type, ret) \
    (t_prop_get32(win, T_PROP_ATOM(prop), T_PROP_ATOM(type), ret))
#define T_PROP_GETA32(win, prop, type, ret, nret) \
    (t_prop_get_array32(win, T_PROP_ATOM(prop), T_PROP_ATOM(type), ret, nret))
#define T_PROP_GETS(win, prop, ret) \
    (t_prop_get_text(win, T_PROP_ATOM(prop), 0, ret))
#define T_PROP_GETSS_TYPE(win, prop, type, ret) \
    (t_prop_get_array_text(win, T_PROP_ATOM(prop), T_PROP_TEXT_##type, ret))
#define T_PROP_GETS_UTF8(win, prop, ret) \
    T_PROP_GETS_TYPE(win, prop, UTF8_STRING, ret)
#define T_PROP_GETSS_UTF8(win, prop, ret) \
    T_PROP_GETSS_TYPE(win, prop, UTF8_STRING, ret)
#define T_PROP_SET32(win, prop, type, val) \
    (t_prop_set32(win, T_PROP_ATOM(prop), T_PROP_ATOM(type), val))
#define T_PROP_SETA32(win, prop, type, val, num) \
    (t_prop_set_array32(win, T_PROP_ATOM(prop), T_PROP_ATOM(type), val, num))
#define T_PROP_SETS(win, prop, val) \
    (t_prop_set_text(win, T_PROP_ATOM(prop), val))
#define T_PROP_ERASE(win, prop) (t_prop_erase(win, T_PROP_ATOM(prop)))
#define T_PROP_MSG(screen, about, msgtype, data0, data1, data2, data3, data4) \
    (t_prop_message(screen, about, T_PROP_ATOM(msgtype), data0, data1, data2, data3, data4, \
    SubstructureNotifyMask | SubstructureRedirectMask))
#define T_PROP_MSG_TO(to, about, msgtype, data0, data1, data2, data3, data4, mask) \
    (t_prop_message_to(to, about, T_PROP_ATOM(msgtype), data0, data1, data2, data3, data4, mask))
G_END_DECLS
#endif
